function Bmfx(){
    this.InitEleUI();
    this.InitOrg();

    this.GetZfStatisYearDw();
    this.GetDwStatisYearDw();
    this.GetYwStatisYearDw();
}

Bmfx.prototype.InitEleUI=function(){
    var form;
    layui.use('form', function(){
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功



        form.render();
    });
    return form;
}

Bmfx.prototype.InitOrg = function() {
    var comboboxm=$("#orgid").ligerComboBox({
        valueField : 'orgid',
        textField : 'orgname',
        selectBoxWidth : 250,
        selectBoxHeight:250,
        treeLeafOnly:false,
        valueFieldID:"hid",
        tree: {url : '../common/get_org_list?orgtype=0',
            checkbox: false,
            nodeWidth:150,
            ajaxType: 'get',
            idFieldName: 'orgid',
            textFieldName:"orgname",
            idField:"orgid",
            parentIDField:"orgparentid"
        },
        onSelected : function(orgid, orgname) {// id为空值，name为选择的值
            $("#hidszdw").val(orgid);
            $("#hidorgname").val(orgname);
            vBmfx.GetZfStatisYearDw();
            vBmfx.GetDwStatisYearDw();
            vBmfx.GetYwStatisYearDw();
        },
        width : 250
    });
    return comboboxm;
}

Bmfx.prototype.GetZfStatisYearDw=function(){
    $("#orgnamezfyear").html($("#hidorgname").val());
    $.ajax({
        type:"GET",
        url:"getzfkhyeardw",
        data:{szdw:$("#hidszdw").val()},
        beforeSend:function(XHR){

        },
        success:function(data){
            data=eval('('+data+')');
            if(data.result>0){
                if(data.items.zfmapdw){
                    var ymdata=[2015,2016,2017,2018,2019,2020,2021,2022];
                    var ywbject=data.items.zfmapdw;
                    var scoreata=[];
                    var maxindex=0;
                    for(l=0;l<ymdata.length;l++){
                        var mvalue=-1;
                        if(ywbject.length>0){
                            for(k=0;k<ywbject.length;k++){
                                if(ywbject[k].yearstr==ymdata[l]){
                                    mvalue=ywbject[k].rank;
                                    if(maxindex<mvalue){
                                        maxindex=mvalue;
                                    }
                                }
                            }
                        }
                        if(mvalue==-1){
                            scoreata.push('');
                        }
                        else{
                            scoreata.push(mvalue);
                        }

                    }
                    InitChatsOrgYear(scoreata,maxindex);
                }
            }
        }
    })
}


Bmfx.prototype.GetDwStatisYearDw=function(){
    $("#orgnamedwyear").html($("#hidorgname").val());
    $.ajax({
        type:"GET",
        url:"getdwkhyeardw",
        data:{szdw:$("#hidszdw").val()},
        beforeSend:function(XHR){

        },
        success:function(data){
            data=eval('('+data+')');
            if(data.result>0){
                if(data.items.dwmapdw){
                    var ymdata=[2015,2016,2017,2018,2019,2020,2021,2022];
                    var ywbject=data.items.dwmapdw;
                    var scoreata=[];
                    var maxindex=0;
                    for(l=0;l<ymdata.length;l++){
                        var mvalue=-1;
                        if(ywbject.length>0){
                            for(k=0;k<ywbject.length;k++){
                                if(ywbject[k].yearstr==ymdata[l]){
                                    mvalue=ywbject[k].rank;
                                    if(maxindex<mvalue){
                                        maxindex=mvalue;
                                    }
                                }
                            }
                        }
                        if(mvalue==-1){
                            scoreata.push('');
                        }
                        else{
                            scoreata.push(mvalue);
                        }

                    }
                    InitChatsOrgDwYear(scoreata,maxindex);
                }
            }
        }
    })
}


Bmfx.prototype.GetYwStatisYearDw=function(){
    $("#orgnameywyear").html($("#hidorgname").val());
    $.ajax({
        type:"GET",
        url:"getywkhyeardw",
        data:{szdw:$("#hidszdw").val(),tempid:$("#hidtempid").val()},
        beforeSend:function(XHR){

        },
        success:function(data){
            data=eval('('+data+')');
            if(data.result>0){
                if(data.items.ywmapdw){
                    var ymdata=[2015,2016,2017,2018,2019,2020,2021,2022];
                    var ywbject=data.items.ywmapdw;
                    var scoreata=[];
                    var maxindex=0;
                    for(l=0;l<ymdata.length;l++){
                        var mvalue=-1;
                        if(ywbject.length>0){
                            for(k=0;k<ywbject.length;k++){
                                if(ywbject[k].yearstr==ymdata[l]){
                                    mvalue=ywbject[k].rank;
                                    if(maxindex<mvalue){
                                        maxindex=mvalue;
                                    }
                                }
                            }
                        }
                        if(mvalue==-1){
                            scoreata.push('');
                        }
                        else{
                            scoreata.push(mvalue);
                        }

                    }
                    InitYwChatsOrgYear(scoreata,maxindex);
                }
            }
        }
    })
}



var vBmfx=null;
$(function(){
    vBmfx=new Bmfx();
})


function InitChatsOrgYear(yeardata,maxindex){
    $("#ChartZfOrgYear").width($(window).width()/3-10);
    $("#ChartZfOrgYear").height(($(window).height()-200));
    var myChart = echarts.init(document.getElementById('ChartZfOrgYear'));
    option = {
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            },
            backgroundColor:'#3187c2',
            textStyle: {
                fontWeight: "normal",
                color: "#aadeff",
                fontSize: 8
            },
            formatter: function(params) {
                var result = '';
                params.forEach(function (item) {
                    //alert(JSON.stringify(item))
                    if(item.value>0){
                        result += "   "+item.marker +item.name+"年：     第 "+ item.value +" 名";
                    }

                });
                return result;
            }

        },



        xAxis: { type: 'category',
            boundaryGap: false,
            data: ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022'],
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#aadeff'
                },
                interval:0
            },
            axisTick:{
                show:false
            },
            axisLine:{
                show:false
            }



        },
        yAxis: {
            inverse:true,
            type: 'value'
            ,axisLabel: {
                show: true,
                textStyle: {
                    color: '#aadeff'
                }
            },
            axisTick:{
                show:false
            },
            axisLine:{
                show:false,
                onZero: false
            },
            splitLine: {           // 分隔线
                show: true,        // 默认显示，属性show控制显示与否
                lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                    color: ['#4170a8'],
                    width: 1,
                    type: 'solid'
                }
            },
            splitArea: {           // 分隔区域
                show: true,       // 默认不显示，属性show控制显示与否
                areaStyle: {       // 属性areaStyle（详见areaStyle）控制区域样式
                    color: ['#305d94','none']
                }
            },
            min:1,
            max:(maxindex+1)%2==0?(maxindex+1):(maxindex+2)
            ,minInterval:1
        },
        grid: {
            left: 10,
            right: 20,
            bottom: 5,
            x:0,
            y:10,
            x2:0,
            containLabel: true
        },
        series: [{
            data: yeardata,
            type: 'line'
            ,itemStyle : {
                normal : {
                    color:'#00FF00',
                    borderColor:'red',
                    lineStyle:{
                        color:'#825c8b',
                        width:4
                    }

                }
            },
            symbolSize: 12//拐点大小

        }]
    };
    myChart.setOption(option);
}



function InitChatsOrgDwYear(yeardata,maxindex){
    $("#ChartDwOrgYear").width($(window).width()/3-15);
    $("#ChartDwOrgYear").height(($(window).height()-200));
    var myChart = echarts.init(document.getElementById('ChartDwOrgYear'));
    option = {
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            },
            backgroundColor:'#3187c2',
            textStyle: {
                fontWeight: "normal",
                color: "#aadeff",
                fontSize: 8
            },
            formatter: function(params) {
                var result = '';
                params.forEach(function (item) {
                    //alert(JSON.stringify(item))
                    if(item.value>0){
                        result += "   "+item.marker +item.name+"年：     第 "+ item.value +" 名";
                    }

                });
                return result;
            }

        },



        xAxis: { type: 'category',
            boundaryGap: false,
            data: ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022'],
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#aadeff'
                },
                interval:0,
                rotate:310

            },
            axisTick:{
                show:false
            },
            axisLine:{
                show:false
            }



        },
        yAxis: {
            inverse:true,
            type: 'value'
            ,axisLabel: {
                show: true,
                textStyle: {
                    color: '#aadeff'
                }
            },
            axisTick:{
                show:false
            },
            axisLine:{
                show:false,
                onZero: false
            },
            splitLine: {           // 分隔线
                show: true,        // 默认显示，属性show控制显示与否
                lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                    color: ['#4170a8'],
                    width: 1,
                    type: 'solid'
                }
            },
            splitArea: {           // 分隔区域
                show: true,       // 默认不显示，属性show控制显示与否
                areaStyle: {       // 属性areaStyle（详见areaStyle）控制区域样式
                    color: ['#305d94','none']
                }
            },
            min:1,
            max:(maxindex+1)%2==0?(maxindex+1):(maxindex+2)
            ,minInterval:1
        },
        grid: {
            left: 10,
            right: 20,
            bottom: 10,
            x:0,
            // y:10,
            x2:0,
            y2:20,
            containLabel: true
        },
        series: [{
            data: yeardata,
            type: 'line'
            ,itemStyle : {
                normal : {
                    color:'#00FF00',
                    borderColor:'red',
                    lineStyle:{
                        color:'#825c8b',
                        width:4
                    }

                }
            },
            symbolSize: 12//拐点大小

        }]
    };
    myChart.setOption(option);
}





function InitYwChatsOrgYear(yeardata,maxindex){
    $("#ChartYwOrgYear").width($(window).width()/3-15);
    $("#ChartYwOrgYear").height(($(window).height()-200));
    var myChart = echarts.init(document.getElementById('ChartYwOrgYear'));
    option = {
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            },
            backgroundColor:'#3187c2',
            textStyle: {
                fontWeight: "normal",
                color: "#aadeff",
                fontSize: 8
            },
            formatter: function(params) {
                var result = '';
                params.forEach(function (item) {
                    //alert(JSON.stringify(item))
                    if(item.value>0){
                        result += "   "+item.marker +item.name+"年：     第 "+ item.value +" 名";
                    }

                });
                return result;
            }

        },



        xAxis: { type: 'category',
            boundaryGap: false,
            data: ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022'],
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#aadeff'
                },
                interval:0
            },
            axisTick:{
                show:false
            },
            axisLine:{
                show:false
            }



        },
        yAxis: {
            inverse:true,
            type: 'value'
            ,axisLabel: {
                show: true,
                textStyle: {
                    color: '#aadeff'
                }
            },
            axisTick:{
                show:false
            },
            axisLine:{
                show:false,
                onZero: false
            },
            splitLine: {           // 分隔线
                show: true,        // 默认显示，属性show控制显示与否
                lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                    color: ['#4170a8'],
                    width: 1,
                    type: 'solid'
                }
            },
            splitArea: {           // 分隔区域
                show: true,       // 默认不显示，属性show控制显示与否
                areaStyle: {       // 属性areaStyle（详见areaStyle）控制区域样式
                    color: ['#305d94','none']
                }
            },
            min:1,
            max:(maxindex+1)%2==0?(maxindex+1):(maxindex+2)
            ,minInterval:1
        },
        grid: {
            left: 10,
            right: 20,
            bottom: 5,

            containLabel: true
        },
        series: [{
            data: yeardata,
            type: 'line'
            ,itemStyle : {
                normal : {
                    color:'#00FF00',
                    borderColor:'red',
                    lineStyle:{
                        color:'#825c8b',
                        width:4
                    }

                }
            },
            symbolSize: 12//拐点大小
//		        ,areaStyle: { normal : {
//		                        	 color: new echarts.graphic.LinearGradient(
//		                                     0, 0, 0, 1,
//		                                   [
//		                                      {offset: 0, color: 'rgba(38,98,160,0.3)'},   // {offset: 0, color: '#2FDE80'},
//		                                      {offset: 1, color: 'rgba(250,250,250,0.3)'}//  {offset: 1, color: '#2FDECA'}
//
//		                                   ])
//
//		                        }
//		                        }
        }]
    };






    myChart.setOption(option);
}
